<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by CodeTlan.
 * User: Ing. Miguel Salas
 * Date: 3/4/12
 * Time: 9:28 PM
 */
class Militancias extends CT_Controller
{
    function __construct(){
        parent::__construct();
        $this->load->model("militancia", "dao");
        $this->load->model("trabajador", "trabajadordao");
    }
    function add(){
        $data["actividad"]=$this->input->post("actividad");
        $data["fecha"]=$this->input->post("fecha");
        $data["activo"]=1;
        $data["estatus"]=1;
        echo $this->_add($data);
    }
    function edit(){
        $data=(array) json_decode($this->input->post("mod"));
        echo $this->_edit($data,array('militancia_k' => $this->input->post('militancia_k')));
    }
    function active()
    {
        echo $this->_edit(array('activo' => $this->input->post('activo')), array('militancia_k' => $this->input->post('militancia_k')));

    }
    function delete()
    {
        echo $this->_edit(array("estatus" => 0), array('militancia_k' => $this->input->post('militancia_k')));
    }
    function find(){
        $result=$this->dao->find('militancia_k, actividad, fecha, activo','',$this->input->post("start"),NUM_ROWS);
        echo $this->getSuccess($result);
    }
    function consultaFind(){

        $params=array(
            "ficha" => $this->input->post('ficha'),
            "fecha_inicio" => $this->input->post('fecha_inicio'),
            "fecha_fin" => $this->input->post('fecha_fin')
        );

        $result=$this->dao->consultaFind('M.actividad, M.fecha',$params,$this->input->post("start"),NUM_ROWS);

        echo $this->getSuccess($result);
    }
}